function loading(){
	if($('.oimg').length>0){
		if($('.oimg').get(0).complete){
			$(".loading-wrapper").hide();
			addload.addssp();
		}
	}
	else{
		$(".loading-wrapper").hide();
		addload.addssp();
	}
}
var navActive = {
	ifNav : $('.footer-five-grid').length != 0,
	addActive : function(){
		if(this.ifNav){
			var footer = $('.footer-five-grid');
			footer.children('div').click(function(){
				$(this).addClass('active cl-f-orange').siblings().removeClass('active cl-f-orange');
			})
		}
	}
}
navActive.addActive();

function lazyloadImg(lazyItem){
	lazyItem.lazyload({
    	effect : "fadeIn",
    	threshold : 100,
    	placeholder : "" //加载图片前占位
	});
}
// 跳转loading
document.onreadystatechange = loading;
 
$(document).ready(function() {
	lazyloadImg($('.lazy'));

	$('.clickable').click(function(event) {
		// 跳转
	});
	/*$('.like').click(function(event) {
		event.stopPropagation();
		var clickable=$(this).parents('.clickable');
		clickable.removeClass('clickable');
		var account=$(this).find('.like-text').text();
		$(this).find('.like-text').text(++account);
		setTimeout(function(){clickable.addClass('clickable');},500);
	});*/
	
	// 布局相关
	var preHeight=$('.index-ver-block').prev('.index-block').find('img').width();
	var verHeight=$('.index-ver-block').width()/2.09*2;
	$('.index-ver-block>div').css('marginBottom',preHeight-verHeight+'px');
	$('.index-ver-block>div:last').css('marginBottom',0);
	var sortW=($(window).width()-50)/4;
	$('.recipe-sort-type a').width(sortW);

	//comfirm样式
	window.alert = function(str){
        $('body').prepend('<div class="comfirm"><div class="comfirm-content"><div class="comfirm-body">'+
            str+'</div><div class="comfirm-footer"><button class="btn cl-b-gray">取消</button><button class="btn cl-b-orange cl-f-white">确定</button></div></div></div>');
        $('.comfirm').fadeIn();
        $('.comfirm-footer .btn').click(function(){
             $('.comfirm').fadeOut().remove();
        });
    };
    //返回顶部
	var winH = $(window).height(),flag = true;
	$(window).on('scroll',function(){
		var scrollPos = $(window).scrollTop();
		if(scrollPos > winH){
			if(flag){
				$('body').prepend('<div class="top">' +
					'<img src="'+img_url+'/top.png" alt="">' +
				'</div>');
				$('.top').on('click',function(){
					$('html,body').animate({
						scrollTop: 0
					}, '500');
				}); 
				flag = false;
			}
			$('.top').removeClass('top-hide').addClass('top-show');
		}else {
			$('.top').removeClass('top-show').addClass('top-hide');
		}
	});  

	$('.nav-href').click(function(e){
		e.preventDefault();
		var url = $(this).attr('data-url');
        if(url == undefined || url == '')
        {
            return false;
        }
        location.href = url;
	});

	// 首页弹出导航
	$('.index-pop').click(function(event){
		$('.pop-nav').slideToggle('fast');
	});
	//随手拍点赞
	/*$('.ssp-blike').click(function(event) {
		event.preventDefault();
		$likeTxt=$(this).siblings('p');
		$likeNum=parseInt($likeTxt.text());
		$likeTxt.text($likeNum+1);
	});*/

	

});
/*
var addload = {
   	isTrue : $('#scroll-wrapper').index() !== -1,
   	addssp : function(){
   		if(this.isTrue) {
   			if($('#scroll-wrapper').height()<$(window).height()-45)
   			{
   				$('.add-loading').remove();
   				return false;
   			}
   			var addload = $('.add-loading');
    		$(window).on('scroll',function(){
				if(isLoading == false)
				{
	    			var scrollPos = $(window).scrollTop(),wrapperH = $('#scroll-wrapper').height();
		    		if(scrollPos > wrapperH - $(window).height() + footH )
		    		{
		    			getMessage();
		    		}
				}
			}); 
   		}
   	}
}
*/
